
/**
 *  删除了例子中的部分代码
 */
import { init } from 'snabbdom/init'
import { classModule } from 'snabbdom/modules/class'
import { propsModule } from 'snabbdom/modules/props'
import { styleModule } from 'snabbdom/modules/style'
import { eventListenersModule } from 'snabbdom/modules/eventlisteners'
import { h } from 'snabbdom/h'
// 前面的代码都用于生成 patch 函数
const patch = init([classModule, propsModule,styleModule,eventListenersModule,])

const container = document.getElementById('container')
// 生成 vnode
const vnode = h('div#container.two.classes', {}, [
  h('span', { style: { fontWeight: 'bold' } }, 'This is bold'),
  ' and this is just normal text',
  h('a', { props: { href: '/bar' } }, 'I\'ll take you places!')
])
// console.log(vnode)
// 更新 dom
patch(container, vnode)



const vnode1 = h('ol',{key:'username-list'},[
  h('li',{key:'name1'},'张三'),
  h('li',{key:'name2'},'李四'),
  h('li',{key:'name3'},'王五')
])
patch(vnode, vnode1)
const vnode2 = h('ol',{key:'username-list'},[
  h('li',{key:'name1'},'张三'),
  h('li',{key:'name2'},'李四'),
  h('li',{key:'name3'},'王五'),
  h('li',{key:'name4'},'赵六'),
  h('li',{key:'name5'},'朱七')
])
document.onclick = ()=>{
  patch(vnode1, vnode2)
}

console.log(vnode1)